package cn.sofwin.day0122.homework.account;

/**
 * 账户
 * @author 仙女本仙
 * @email 1335651292@qq.com
 */
public class Account {
    private int id;
    private double balance;
    private double annualInterestRate;

    public Account(int id, double balance, double annualInterestRate) {
        this.id = id;
        this.balance = balance;
        this.annualInterestRate = annualInterestRate;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    public void setAnnualInterestRate(double annualInterestRate) {
        this.annualInterestRate = annualInterestRate;
    }

    /**
     * 提款
     * @param amount 提款金额
     */

    public void withdraw(double amount,Customer customer){
        if(amount <= this.balance){
            this.balance -= amount;
            System.out.println("成功取出：" + amount);
            return;
        }
            System.out.println("余额不足，取款失败");
            System.out.print("Customer [" + customer.getFirstName()+ ", " + customer.getLastName() + "]");
            System.out.print("has a account: id is " + this.id);
            System.out.println(" annualInterestRate is" + this.annualInterestRate*100);
            System.out.println("％,balance is " + this.balance);

    }

    /**
     * 存款
     * @param amount 存款金额
     */
    public void deposit(double amount){
        this.balance += amount;
        System.out.println("成功存入：" + amount);
    }

}
